<!--
 * @Author: WangShuai 1830773767@qq.com
 * @Date: 2024-01-14 20:36:07
 * @LastEditors: WangShuai 1830773767@qq.com
 * @LastEditTime: 2025-06-17 18:11:37
 * @FilePath: \vue3_admin_template\project\src\views\screen\index.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <div class="containerScreen">
    <!-- 数据大屏展示内容区域 -->
    <div class="screen" ref="screen">
      <div class="top">
        <!-- 数据大屏顶部 -->
        <Top></Top>
      </div>
      <div class="bottom">
        <div class="left">
          <Tourist class="tourist"></Tourist>
          <Sex class="sex"></Sex>
          <Age class="age"></Age>
        </div>
        <div class="center">
          <Map class="map"></Map>
          <Line class="line"></Line>
        </div>
        <div class="right">
          <Rank class="rank"></Rank>
          <Year class="year"></Year>
          <Couter class="couter"></Couter>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue'
import Top from './component/Top/index.vue'
import Tourist from './component/Tourist/index.vue'
import Sex from './component/Sex/index.vue'
import Age from './component/Age/index.vue'
//中间
import Map from './component/Map/index.vue'
import Line from './component/Line/index.vue'
//引入右侧三个组件
import Rank from './component/Rank/index.vue'
import Year from './component/Year/index.vue'
import Couter from './component/Couter/index.vue'
//获取数据大屏展示的盒子内容DOM元素
let screen = ref()
onMounted(() => {
  const element = document.documentElement
  if (element.requestFullscreen) {
    element.requestFullscreen()
  } else if ((element as any).mozRequestFullScreen) {
    ;(element as any).mozRequestFullScreen() // Firefox
  } else if ((element as any).webkitRequestFullscreen) {
    ;(element as any).webkitRequestFullscreen() // Chrome/Safari
  } else if ((element as any).msRequestFullscreen) {
    ;(element as any).msRequestFullscreen() // IE/Edge
  }
  screen.value.style.transform = `scale(${getScale()}) translate(-50%,-50%)`
})
//定义大屏缩放比例
function getScale(w = 1920, h = 1080) {
  let ww = window.innerWidth / w
  let wh = window.innerHeight / h
  return ww < wh ? ww : wh
}
//监听视口变化
window.onresize = () => {
  screen.value.style.transform = `scale(${getScale()}) translate(-50%,-50%)`
}
</script>

<style lang="scss" scoped>
.containerScreen {
  width: 100vw;
  height: 100vh;
  background: url('./images/bg.png') no-repeat;
  background-size: cover;
  .screen {
    position: fixed;
    width: 1920px;
    height: 1080px;
    // background-color: red;
    transform-origin: left top;
    left: 50%;
    top: 50%;
    .top {
      width: 100%;
      height: 40px;
      // background: cyan;
    }
    .bottom {
      display: flex;
      .left {
        flex: 1;
        // height: calc(100vh - 40px);
        height: calc(1080px - 40px);
        // background-color: red;
        display: flex;
        flex-direction: column;
        margin-right: 5px;
        .tourist {
          flex: 1.2;
          //   background-color: rgb(0, 255, 21);
        }
        .sex {
          flex: 1;
          //   background-color: rgb(255, 94, 0);
        }
        .age {
          flex: 1;
          //   background-color: rgb(47, 0, 255);
        }
      }
      .center {
        flex: 2;
        display: flex;
        flex-direction: column;
        // justify-content: center;
        // align-items: center;
        .map {
          flex: 5;
          // background-color: rgb(105, 199, 17);
        }
        .line {
          flex: 1;
          //   background-color: rgb(104, 104, 206);
        }
      }
      .right {
        flex: 1;
        display: flex;
        flex-direction: column;
        margin-left: 5px;
        .rank {
          flex: 1;
          //   background-color: red;
        }
        .year {
          flex: 1.5;
          //   background-color: rgba(29, 185, 63, 0.555);
        }
        .couter {
          flex: 1;
          //   background-color: rgb(9, 12, 163);
        }
      }
    }
  }
}
</style>
